package org.ethan.practice.no_select_tab;


import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import java.util.List;

/**
 * @ClassName: TabFragmentPagerAdapter
 * @Desc:
 * @Author: ethan
 * @CreateDate: 2019/9/18 15:29
 */
public class TabFragmentPagerAdapter extends FragmentStatePagerAdapter {

    private List<Fragment> mFragments;
    private List<String> mTitle;

    public TabFragmentPagerAdapter(FragmentManager fm, List<Fragment> mFragments) {
        super(fm);
        this.mFragments = mFragments;
    }

    public TabFragmentPagerAdapter(FragmentManager fm, List<Fragment> mFragments, List<String> mTitle) {
        super(fm);
        this.mFragments = mFragments;
        this.mTitle = mTitle;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments == null ?null : mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mFragments == null ? 0:mFragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitle == null || mTitle.size() == 0 ? null :mTitle.get(position);
    }
}
